var e = require("../../@babel/runtime/helpers/interopRequireDefault")(require("../../@babel/runtime/regenerator")), t = require("../../@babel/runtime/helpers/asyncToGenerator"), a = getApp(), n = (require("../../utils/api.js"), 
require("../../utils/md5"), require("../../http/activityApi.js")), r = "http://newimg.ap1983.com/prod/20220121/fa2c27fde04548fa92d549ac20accecc.png", o = "http://newimg.ap1983.com/prod/20220121/836d1ef4d999420cb0944ef44c827436.png", c = "http://newimg.ap1983.com/prod/20220121/e25902cc39554f0ebf0a0360c9c22e13.png", s = "http://newimg.ap1983.com/prod/20220121/7bdb6df6af0149c7a133d15ba73d92f7.png", i = "http://newimg.ap1983.com/prod/20220121/352e3ea0802d457d93fbe85f318632be.png";

Page({
    code: "",
    onShowCounter: 0,
    data: {
        systemInfo: a.data.systemInfo,
        showOfficial: !0,
        isCodeDraw: !1,
        bgUrl: "http://newimg.ap1983.com/prod/20220121/11a659bd58ca464ca1d5039f09340f8a.png",
        titleUrl: "http://newimg.ap1983.com/prod/20220121/5549e8a9913a4466b2443ed11e3f4a21.png",
        logoUrl: "http://newimg.ap1983.com/prod/20220121/ee5884efb4614ba1b82b471754e9bb66.png",
        star1Url: r,
        star2Url: o,
        star3Url: c,
        star4Url: s,
        star5Url: i,
        starUrlList: [ r, o, c, s, i ]
    },
    onLoad: function(e) {
        e.scene ? this.code = e.scene : this.code = "", console.log("扫码：", this.code || "无"), 
        this.loadData();
    },
    onShow: function() {},
    userInfoOnTap: function() {
        var e = this, t = wx.createSelectorQuery();
        t.select("#userInfoBtn").boundingClientRect(), t.exec(function(t) {
            e.setData({
                showUserInfo: !e.data.showUserInfo,
                userInfoTop: t[0].top
            });
        });
    },
    mengRankOnTap: function() {
        var e = this, t = wx.createSelectorQuery();
        t.select("#mengRankBtn").boundingClientRect(), t.exec(function(t) {
            e.setData({
                showMengRank: !e.data.showMengRank,
                mengRankTop: t[0].top
            });
        });
    },
    ruleOnTap: function() {
        var e = this, t = wx.createSelectorQuery();
        t.select("#ruleBtn").boundingClientRect(), t.exec(function(t) {
            e.setData({
                showRule: !e.data.showRule,
                ruleTop: t[0].top
            });
        });
    },
    closeResultOnTap: function() {
        this.setData({
            showResult: !1
        });
    },
    scanOnTap: function() {
        a.appScan(!1);
    },
    closeOfficialOnTap: function() {
        this.setData({
            showOfficial: !1
        });
    },
    loadData: function() {
        var r = this;
        return t(e.default.mark(function t() {
            var o, c, s;
            return e.default.wrap(function(e) {
                for (;;) switch (e.prev = e.next) {
                  case 0:
                    if (a.showLoading(), e.prev = 1, !r.code || r.data.isCodeDraw) {
                        e.next = 9;
                        break;
                    }
                    return e.next = 5, n.scanGiftScan(r.code);

                  case 5:
                    o = e.sent, c = "集齐5颗星球，恭喜获得神券", o.data.coupon || (c = "还差" + (5 - o.data.starNum) + "个即可领取神券"), 
                    r.setData({
                        isCodeDraw: !0,
                        showResult: !0,
                        realActivateCount: o.data.starNum,
                        coupon: o.data.coupon,
                        tips: c
                    });

                  case 9:
                    e.next = 13;
                    break;

                  case 11:
                    e.prev = 11, e.t0 = e.catch(1);

                  case 13:
                    return e.prev = 13, e.next = 16, n.scanGiftHome();

                  case 16:
                    return s = e.sent, r.setData({
                        ruleDesc: s.data.activityRule
                    }), e.next = 20, n.scanGiftUserInfo();

                  case 20:
                    return s = e.sent, r.setData({
                        userInfo: {
                            AllCouponAmount: s.data.giveGiftPrice ? s.data.giveGiftPrice : 0,
                            MengVal: s.data.strengthNum
                        },
                        realActivateCount: s.data.starNum
                    }), e.next = 24, n.scanGiftRank(5);

                  case 24:
                    s = e.sent, r.setData({
                        rankingList: s.data
                    }), e.next = 31;
                    break;

                  case 28:
                    e.prev = 28, e.t1 = e.catch(13), console.log(e.t1);

                  case 31:
                    return e.prev = 31, wx.hideLoading(), e.finish(31);

                  case 34:
                  case "end":
                    return e.stop();
                }
            }, t, null, [ [ 1, 11 ], [ 13, 28, 31, 34 ] ]);
        }))();
    }
});